package com.ruoyi.hospital.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.hospital.domain.Hospitals;
import com.ruoyi.hospital.mapper.HospitalsMapper;
import com.ruoyi.hospital.service.HospitalsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;

@Service
public class HospitalsServiceImpl extends ServiceImpl<HospitalsMapper, Hospitals> implements HospitalsService {

    @Autowired
    private HospitalsMapper hospitalsMapper;

    @Override
    public boolean deleteBatchIds(List<String> hospitalIds) {
        // 转换为字符串列表
        List<String> stringIds = hospitalIds.stream().map(Object::toString).collect(Collectors.toList());
        return hospitalsMapper.deleteHospitalsByHospitalIds(stringIds) > 0;
    }

    @Override
    public List<Hospitals> selectHospitalsList(Hospitals hospitals) {
        return hospitalsMapper.selectHospitalsList(hospitals);
    }

    @Override
    public Hospitals selectHospitalsByHospitalId(String hospitalId) {
        return hospitalsMapper.selectHospitalsByHospitalId(hospitalId);
    }

    @Override
    public boolean insertHospitals(Hospitals hospitals) {
        UUID uuid = UUID.randomUUID();
        String hospitalId = uuid.toString();
        hospitals.setHospitalId(hospitalId);
        return hospitalsMapper.insertHospitals(hospitals) > 0;
    }

    @Override
    public int updateHospitals(Hospitals hospitals) {
        return hospitalsMapper.updateHospitals(hospitals);
    }

    @Override
    public Class<Hospitals> getEntityClass() {
        return Hospitals.class;
    }
}